local zhangchou = fk.CreateSkill {
  name = "ls__zhangchou",
  tags = { "Turn" },
}

Fk:loadTranslationTable{
  ["ls__zhangchou"] = "掌筹",
  [":ls__zhangchou"] = "回合技，当其他角色成为【杀】的目标后，你可摸一张牌，令此【杀】效果增加目标角色失去一个策略，若如此做，此【杀】被抵消后，你失去1点体力并发现两张锦囊牌，然后“掌筹”于此轮无效。",
  ["#ls__zhangchou-invoke"] = "掌筹：你可以将%arg对%src的效果增加失去策略",
  ["zhangchou_slash_skill"] = "杀",
  ["#zhangchou_discovery"] = "掌筹：选择两张牌获得",

  ["$ls__zhangchou1"] = "精细入微，策敌制胜。",
  ["$ls__zhangchou2"] = "妙策如神，精兵强将，安有不胜之理？",
}
local ls = require "packages/lvshi/utility"

zhangchou:addEffect(fk.TargetConfirmed, {
  anim_type = "special",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(zhangchou.name) and data.card.trueName == "slash" and target ~= player then
      return player:usedSkillTimes(zhangchou.name) == 0
    end
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(player, { skill_name = zhangchou.name,
    prompt = "#ls__zhangchou-invoke:"..target.id.."::"..data.card:toLogString() })
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, self.name)
    local use_card = data.card:clone()
    local c = table.simpleClone(data.card)
    for k, v in pairs(c) do
      use_card[k] = v
    end
    use_card.skill = Fk.skills["zhangchou_slash_skill"]
    data.card = use_card
  end,
})

zhangchou:addEffect(fk.CardEffectCancelledOut, {
  anim_type = "negative",
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(zhangchou.name) and data.card.trueName == "slash" then
      return data.card.skill == Fk.skills["zhangchou_slash_skill"] and not player.dead
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:loseHp(player, 1, zhangchou.name)
    local cards = ls.discover(player, "trick", 3)
    local choosed_cards, _ = room:askToChooseCardsAndChoice(player, {
      cards = cards,
      choices = {"OK"},
      skill_name = zhangchou.name,
      prompt = "#zhangchou_discovery",
      min_num = 2,
      max_num = 2,
      all_cards = cards
    })
    if #choosed_cards > 0 then
      room:obtainCard(player, choosed_cards, true, fk.ReasonJustMove, player, zhangchou.name)
      room:invalidateSkill(player, zhangchou.name, "-round")
    end
  end,
})

return zhangchou